#pragma once


#define SUPPORTED_SAMPLING_RATE 44100

// header of wav file 
typedef struct{
	char rID[4];            // 'RIFF' 
	long int rLen;
	  
	char wID[4];            // 'WAVE' 
	  
	char fId[4];            // 'fmt ' 
	long int pcm_header_len;   // varies... 
	short int wFormatTag;
	short int nChannels;      // 1,2 for stereo data is (l,r) pairs 
	long int nSamplesPerSec;
	long int nAvgBytesPerSec;
	short int nBlockAlign;      
	short int nBitsPerSample;
} WAV_HDR;
 
   
// header of wav file 
typedef struct{
	char dId[4];            // 'data' or 'fact' 
	long int dLen;
//   unsigned char *data; 
} CHUNK_HDR;


class KWavReader
{
public:
	KWavReader();
	virtual ~KWavReader();
	bool OpenWavFile(const char *wav_file_name);
	bool IsOk() const;
	unsigned int GetSampleCnt() const;
	bool IsStereo() const;
	const short* GetSamplePtr() const;
	unsigned int GetFreq() const;
 
protected:  
	unsigned int mFreq;
	unsigned int mChannelCnt;
	unsigned int mSampleCnt;
	unsigned int mBitsPerSamp;
	short* mpSamples;
};